<!--
 * @Description: 
 * @Version: V1.0.0
 * @Author: 周艳凯 484894717@qq.com
 * @Date: 2024-09-27 16:48:55
 * @LastEditors: 周艳凯 484894717@qq.com
 * @LastEditTime: 2024-10-18 10:13:42
 * @FilePath: item-message.vue
 * Copyright 2024 Marvin, All Rights Reserved. 
 * 2024-09-27 16:48:55
-->
<template>
  <div v-if="$slots.help" :class="classNames">
    <div>
      <slot name="help"></slot>
    </div>
  </div>
  <div v-if="error.length > 0" :class="errorclassNames">
    <div v-for="(item, index) in error" :key="index">
      {{ item }}
    </div>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent, inject } from "vue";
import context from "../arco-form/context.js";
// import svgIcon from "../arco-icon/index.vue";
const icon = defineComponent({
  name: "Card",
  options: {
    // 虚拟化节点
    virtualHost: true,
  },
  props: {
    error: {
      type: Array,
      default: () => [],
    },
    help: {
      type: String,
      default: "",
    },
  },
  emits: {
    close: () => true,
    afterClose: () => true,
  },
  setup(props, { slots }) {
    const prefixCls = "arco-form-item-message";
    const formCtx = inject(context.formInjectionKey, {});
    console.log(formCtx, "1");
    console.log(slots.help, "我是什么值？？");

    const classNames = computed(() => {
      return [
        prefixCls,
        {
          [`${prefixCls}-help`]: props.help || slots.help,
        },
      ];
    });

    const errorclassNames = computed(() => {
      return [prefixCls];
    });

    return {
      prefixCls,
      classNames,
      errorclassNames,
    };
  },
});
export default icon;
</script>

<style scoped>
/* @import "./index.scss"; */
</style>
